package net.huashitong.synthetical.jobOversee.Service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import net.huashitong.synthetical.jobOversee.dao.DutyUnitDao;
import net.huashitong.synthetical.jobOversee.entity.DutyUnit;
import net.huashitong.synthetical.jobOversee.filter.DutyUnitFilter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DutyUnitService extends StringPKService<DutyUnit> {

    @Autowired
    private DutyUnitDao dao;

    @Autowired
    private SysTableService sysTableService;

    @Override
    protected BaseDao<DutyUnit, String> getDao() {
        return dao;
    }

    /**
     * 保存前调用  设置主键sysId
     * @param obj
     */
    @Override
    protected void beforeSave(DutyUnit obj) {
        obj.setSysId(sysTableService.updateMaxSysId("t_dutyunit",null));
    }

    /**
     * 主查询入口
     */
    public List<DutyUnit> getUnitInfo(DutyUnitFilter filter)
    {
        return dao.getunitInfo(filter);
    }

    /**
     * 新增小分队
     */
    public void saveGroup(DutyUnitFilter filter)
    {
        DutyUnit unit  = new DutyUnit();
        BeanUtils.copyProperties(filter,unit);
        save(unit);

    }
}
